﻿<UserControl x:Class="XDraw.Controls.RadialGradientBrushEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:xdCtrl="clr-namespace:XDraw.Controls"
             mc:Ignorable="d"
             Loaded="UserControl_Loaded">
  
  <DockPanel DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Brush}">
    <xdCtrl:GradientStopEditor DockPanel.Dock="Bottom" Height="120" Margin="0,2,0,0"
                               GradientStops="{Binding Path=GradientStops}"/>

    <CheckBox DockPanel.Dock="Bottom" Margin="3,1" Content="Lock origin to center"
              IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=LockOrigionToCenter, Mode=TwoWay}"/>

    <Slider DockPanel.Dock="Right" Orientation="Vertical" Minimum="0.0" Maximum="2.0" Margin="2,0,0,0" IsDirectionReversed="True" 
            Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=OuterSpace}"
            ToolTip="Zoom"/>

    <Canvas SizeChanged="Canvas_SizeChanged" x:Name="Canvas" MinWidth="200" MinHeight="200">
      <Rectangle Stroke="Black" StrokeThickness="1" x:Name="OuterBorder"/>
      <Rectangle Stroke="Black" StrokeThickness="1" Fill="{Binding}" x:Name="InnerBorder"/>

      <Ellipse Stroke="DarkGray" StrokeThickness="1" x:Name="RadialEllipse"/>

      <Rectangle Fill="DarkGray" Stroke="#01ffffff" StrokeThickness="2" x:Name="OriginXLine"
                 ToolTip="Origin"
                 Width="3" 
                 Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Canvas}, Path=ActualHeight}"
                 Cursor="SizeWE"
                 MouseLeftButtonDown="Element_MouseLeftButtonDown"
                 MouseLeftButtonUp="Element_MouseLeftButtonUp"
                 MouseMove="Element_MouseMove"/>

      <Rectangle Fill="DarkGray" Stroke="#01ffffff" StrokeThickness="2" x:Name="OriginYLine"
                 ToolTip="Origin"
                 Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Canvas}, Path=ActualWidth}" 
                 Height="3"
                 Cursor="SizeNS"
                 MouseLeftButtonDown="Element_MouseLeftButtonDown"
                 MouseLeftButtonUp="Element_MouseLeftButtonUp"
                 MouseMove="Element_MouseMove"/>

      <Rectangle Fill="#01ffffff" x:Name="OriginXY"
                 ToolTip="Origin"
                 Width="5" Height="5"
                 Cursor="SizeAll"
                 MouseLeftButtonDown="Element_MouseLeftButtonDown"
                 MouseLeftButtonUp="Element_MouseLeftButtonUp"
                 MouseMove="Element_MouseMove"/>

      <Ellipse Width="10" Height="10" Fill="#7fffffff" Stroke="Blue" StrokeThickness="1" x:Name="CenterPoint"
               ToolTip="Center"
               Cursor="SizeAll"
               MouseLeftButtonDown="Element_MouseLeftButtonDown"
               MouseLeftButtonUp="Element_MouseLeftButtonUp"
               MouseMove="Element_MouseMove"/>

      <Ellipse Width="10" Height="10" Fill="#7fffffff" Stroke="Blue" StrokeThickness="1" x:Name="RadiusXPoint"
               ToolTip="Radius X"
               Cursor="SizeWE"
               MouseLeftButtonDown="Element_MouseLeftButtonDown"
               MouseLeftButtonUp="Element_MouseLeftButtonUp"
               MouseMove="Element_MouseMove"/>

      <Ellipse Width="10" Height="10" Fill="#7fffffff" Stroke="Blue" StrokeThickness="1" x:Name="RadiusYPoint"
               ToolTip="Radius Y"
               Cursor="SizeNS"
               MouseLeftButtonDown="Element_MouseLeftButtonDown"
               MouseLeftButtonUp="Element_MouseLeftButtonUp"
               MouseMove="Element_MouseMove"/>
    </Canvas>
  </DockPanel>
</UserControl>
